<template>
  <a-modal v-model='visible' :title=title @cancel='cancel' @ok='sure'>
    <a-form-model :model='item' :label-col='{span :8 }' :wrapper-col='{ span: 12 }'>
      <a-form-model-item label='按期受理率单位'>
        <a-input-number
          v-model='item.acceptOnTime' placeholder='请输入' style='width: 200px'
          :formatter='value => `${value}%`'
          :parser="value => value.replace('%', '')"
          :precision='2'
          :min='0'
          v-decorator="['workHour', {rules: [{required: true, message: '请输入工时(最多输入两位小数)'}]}]" />
      </a-form-model-item>
      <a-form-model-item label='按期答复率'>
        <a-input-number
          v-model='item.replyOnTime' placeholder='请输入' style='width: 200px'
          :formatter='value => `${value}%`'
          :parser="value => value.replace('%', '')"
          :precision='2'
          :min='0'
          v-decorator="['workHour', {rules: [{required: true, message: '请输入工时(最多输入两位小数)'}]}]" />
      </a-form-model-item>
      <a-form-model-item label='回访核实率'>
        <a-input-number
          v-model='item.returnVisit' placeholder='请输入' style='width: 200px'
          :formatter='value => `${value}%`'
          :parser="value => value.replace('%', '')"
          :precision='2'
          :min='0'
          v-decorator="['workHour', {rules: [{required: true, message: '请输入工时(最多输入两位小数)'}]}]" />
      </a-form-model-item>
      <a-form-model-item label='群众满意率'>
        <a-input-number
          v-model='item.massSatisfiedRate' placeholder='请输入' style='width: 200px'
          :formatter='value => `${value}%`'
          :parser="value => value.replace('%', '')"
          :precision='2'
          :min='0'
          v-decorator="['workHour', {rules: [{required: true, message: '请输入工时(最多输入两位小数)'}]}]" />
      </a-form-model-item>
      <a-form-model-item label='三方通话来电量'>
        <a-input-number
          :min='0'
          v-decorator="['number', {rules: [{required: true, message: '请输入人数(正整数)'}]}]"
          v-model='item.sfthCallNum' placeholder='请输入' style='width: 200px' />
      </a-form-model-item>
      <a-form-model-item label='三方通话接通率'>
        <a-input-number
          v-model='item.sfthAnswerRate' placeholder='请输入' style='width: 200px'
          :formatter='value => `${value}%`'
          :parser="value => value.replace('%', '')"
          :precision='2'
          :min='0'
          v-decorator="['workHour', {rules: [{required: true, message: '请输入工时(最多输入两位小数)'}]}]" />
      </a-form-model-item>
    </a-form-model>
  </a-modal>
</template>

<script>
import reportsHandleMonthlyService from '@/myService/ReportsHandleMonthlyService'

export default {
  name: 'EditStatisticsModal',
  data() {
    return {
      visible: false,
      item: {},
      title: '编辑(数值为空则不修改)'
    }
  },
  methods: {
    open(row) {
      this.item = row
      this.visible = true
    },
    cancel() {
      this.visible = false
    },
    sure() {
      console.log(this.item)
      let data = {
        monthId: this.item.monthId,
        acceptOnTime: this.item.acceptOnTime===null?null:this.item.acceptOnTime.toString().replace(/%/g, '')+"%",
        replyOnTime: this.item.replyOnTime===null?null:this.item.replyOnTime.toString().replace(/%/g, '')+"%",
        returnVisit: this.item.returnVisit===null?null:this.item.returnVisit.toString().replace(/%/g, '')+"%",
        massSatisfiedRate: this.item.massSatisfiedRate===null?null:this.item.massSatisfiedRate.toString().replace(/%/g, '')+"%",
        sfthCallNum: this.item.sfthCallNum,
        sfthAnswerRate: this.item.sfthAnswerRate===null?null:this.item.sfthAnswerRate.toString().replace(/%/g, '')+"%",
      }
      reportsHandleMonthlyService.editStatisticsModal(data).then(res => {
        if (res.success) {
          this.$message.success('更新成功')
          this.$emit('updateOrder')
          this.cancel()
        } else {
          this.$message.error(res.message)
        }
      })
    }
  }
}
</script>

<style scoped>

</style>